<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>同步异步</title>
</head>
<body>
	<button id='but'>同步异步</button>

	<script type="text/javascript">
	var but = document.getElementById('but');

	but.onclick = function()
	{
		var i = 100;

		var x = new XMLHttpRequest;

		x.onreadystatechange = function()
		{
			if(x.readyState== 4 && x.status ==200)
			{
				
				i = i+parseInt(x.responseText);

			}
		}
		//true  异步     false  同步
		x.open('GET','6.php',false);  


		x.send();

		alert(i);
	}


	</script>
</body>
</html>